package source.display
{
	import flash.display.*;
	import flash.geom.Matrix;
	import flash.net.*;
	import flash.text.*;

	public class ItemDisplay extends Sprite
	{
		
		[Embed(source='C:/WINDOWS/fonts/GOTHIC.TTF', fontFamily="century", 
		mimeType="application/x-font-truetype")]
		public var centuryGothic:String;
		
		private var title:String;
		private var description:String;
		private var link:String;
		private var itemWidth:Number;
		private var itemHeight:Number;
		
		public function ItemDisplay( title:String, description:String,
								link:String, width:Number, height:Number )
		{
			
			this.buttonMode = true;
			this.mouseChildren = false;	
			this.title = title;
			this.description = description;
			this.link = link;
			this.itemWidth = width;
			this.itemHeight = height;
		
			draw();
			
		}
		
		private function draw():void
		{
			
			var matrix:Matrix = new Matrix( Math.cos( 1.571 ), Math.sin( 1.571),
								-(Math.sin( 1.571 ) ), Math.cos( 1.571 ) );
			
			graphics.beginGradientFill( GradientType.LINEAR, [0x000000, 0xdddddd],
										[1.0, 0.3],	[72, 200], matrix );
			graphics.drawRoundRect( 0, 0, itemWidth, itemHeight, 12, 8 );
			graphics.endFill();
			
			var textField:TextField = new TextField();
			textField.mouseEnabled = true;
			
			var format:TextFormat = new TextFormat();
			format.color = 0xffffff;
			format.size = 9;			
			textField.embedFonts = true;
			textField.antiAliasType = AntiAliasType.ADVANCED;
			format.font = "century";
			textField.defaultTextFormat = format;
			
			textField.text = title;
			
//			textField.textColor = 0xffffff;
			textField.wordWrap = true;
			
			addChild( textField );
			textField.height = itemHeight;
			textField.width = itemWidth * 0.9;
			textField.x = ( itemWidth - textField.width ) / 2;
			textField.y = 2;
			trace( textField.textHeight );
			
		}
		
		public function getLink():void
		{
			
			navigateToURL( new URLRequest( this.link ) );
			
		}
		
	}
	
}